package model

import (
	"github.com/jinzhu/gorm"
)

var DB *gorm.DB

func InitDB() *gorm.DB {
	db, err := gorm.Open("postgres", "host=127.0.0.1 port=5432 user=postgres dbname=graduate_student password=011014 sslmode=disable")
	if err != nil {
		panic("数据库连接失败, err:" + err.Error())
	}
	db.AutoMigrate(&Admin{}, &Examinee{})

	DB = db
	return db
}

func GetDB() *gorm.DB {
	return DB
}
